package com.ec.rs.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.ec.common.exception.BadRequestException;
import lombok.Getter;

@Getter
public enum RequestStatus {
    PENDING("pending", "待审核"),
    APPROVED("approved", "已通过"),
    REJECTED("rejected", "已拒绝");

    @EnumValue
    private final String value;
    private final String desc;

    RequestStatus(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static RequestStatus of(String value) {
        if ("pending".equals(value)) {
            return PENDING;
        }
        if ("approved".equals(value)) {
            return APPROVED;
        }
        if ("rejected".equals(value)) {
            return REJECTED;
        }
        throw new BadRequestException("请求状态错误");
    }
}